package servlet;

import entity.News;
import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;
import service.NewsDaoService;

import java.io.IOException;
import java.util.List;

@WebServlet("/articleByUid")
public class ArticleByUid extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        NewsDaoService nds = new NewsDaoService();
        HttpSession session=request.getSession();

        int uid = Integer.parseInt(request.getParameter("uid"));
        int state = Integer.parseInt(request.getParameter("state"));

        NewsDaoService news = new NewsDaoService();
        List uidnews = news.selectNewsByUid(uid, state);
        session.setAttribute("newsbyuid",uidnews);
        response.sendRedirect("./WinterTourism/material/template/Adminto/html/articleByUid.jsp");


    }
}
